package com.clstu.utility;

import java.util.Scanner;

/**
 * 这是一个输入输出的工具类
 */
public class IOUtility {
    private static final Scanner scanner = new Scanner(System.in);

    /** 获取字符串的前n个字符 */
    public static String readString(int n){
        String input = scanner.next();
        char[] chars = input.toCharArray();
        if(chars.length<=n) {
            return input;//返回前n个字符
        }else {
            return new String(chars,0,n);
        }
    }

    /** 获取一行输入 */
    public static String readString(){
        return scanner.next();
    }

}
